// 
// Decompiled by Procyon v0.5.30
// 

package com.baturu.vin.benz.dto.footnote;

import com.baturu.vin.benz.dto.BenzVinInfoDTO;
import com.baturu.vin.benz.service.impl.util.BenzValidateCodeBUtil;

public class FootnoteRev9Color extends FootnoteRev9 {
    private static int COLOR_COLUMN_FOOTNOTE_INDEX = 0;
    private static int COLOR_COLUMN_ES2_INDEX = 1;
    private static int COLOR_COLUMN_COLOR_INDEX = 2;
    private static int COLOR_COLUMN_CODE_INDEX = 3;
    private static int COLOR_COLUMN_LINK_INDEX = 4;
    private static int COLOR_COLUMN_SIZE = 5;

    public FootnoteRev9Color() {
        this.isColor = true;
    }


    public void setColorInfo(FootnoteRev9Color fn) {
        this.es2Codes = fn.getEs2Codes();
        this.codeBs = fn.getCodeBs();
        this.linkedFoootnotes = fn.getLinkedFoootnotes();
        this.needToReprocessText = fn.needToReprocessText;
        this.hasLink = fn.hasLinkedFootnotes();
        this.isAccessoryFootnote = fn.isAccessoryFootnotes();
    }

    @Override
    public int isValid(FootnoteList fnl, BenzVinInfoDTO benzVinInfoDTO, int statusCKD) {
        boolean rV = true;
        if (this.hasBeenChecked) {
            return this.lastValidReturnValue;
        }
        if (this.codeBs != null && this.codeBs.length() > 0) {
            String codeB = this.codeBs;

            rV = BenzValidateCodeBUtil.validateCodeB(benzVinInfoDTO.getSaCodeSet(), codeB, "D");
        }
        if (!rV) {
            return this.setValid(2);
        }
        BenzValidateCodeBUtil.scorecodeBString(benzVinInfoDTO.getSaCodeSet(), this);
        String linkedFootnotes = this.getLinkedFoootnotes();
        if (linkedFootnotes != null && linkedFootnotes.length() > 0) {
            FootnoteList fn = fnl.getFootnotes(linkedFootnotes).getFootnotesByType(FootnoteRev9Serial.class);
            if (fn != null && fn.size() > 0) {
                FootnoteList filteredLinkFootnotes = fn.getFilteredFootNoteList(fnl, benzVinInfoDTO, statusCKD);
                if (fn.size() == filteredLinkFootnotes.size()) {
                    int partFootnoteStatus = -1;
                    for (int i = 0; i < filteredLinkFootnotes.size(); ++i) {
                        Footnote currentFootnote = filteredLinkFootnotes.get(i);
                        int val = currentFootnote.getValidStatus();
                        if (val == 0) {
                            rV = true;
                            partFootnoteStatus = val;
                            break;
                        }
                        if (val == 1) {
                            rV = false;
                            partFootnoteStatus = val;
                            break;
                        }
                        if (val == 8) {
                            partFootnoteStatus = val;
                        } else if (partFootnoteStatus != 8) {
                            if (val == 7 || val == 6) {
                                partFootnoteStatus = val;
                            } else if (partFootnoteStatus != 7 && partFootnoteStatus != 6) {
                                partFootnoteStatus = val;
                            }
                        }
                    }
                    if (rV && (partFootnoteStatus == 6 || partFootnoteStatus == 4 || partFootnoteStatus == 3 || partFootnoteStatus == 5)) {
                        rV = false;
                    }
                }
            } else {
                rV = false;
                if (this.codeBScore > 0.0f) {
                    this.codeBScore = 0.0f;
                }
            }
        }
        if (rV) {
            return this.setValid(9);
        }
        return this.setValid(2);
    }
}
